//
//  PictureModel.m
//  项目A_百思不得姐
//
//  Created by wudongyang on 16/5/19.
//  Copyright © 2016年 wudongyang. All rights reserved.
//

#import "PictureModel.h"

@implementation PictureModel
-(void)setValue:(id)value forUndefinedKey:(NSString *)key{

    if ([key isEqualToString:@"u"]) {
        NSDictionary *dic = value;
        _umodel = [UModel new];
        [self.umodel setValuesForKeysWithDictionary:dic];
    }
    if ([key isEqualToString:@"video"]) {
        NSDictionary *dic = value;
        _videoModel = [VideoModel new];
        [self.videoModel setValuesForKeysWithDictionary:dic];
    }
    if ([key isEqualToString:@"gif"]) {
        NSDictionary *dic = value;
        _gifModel = [GifModel new];
        [self.gifModel setValuesForKeysWithDictionary:dic];
    }
    if ([key isEqualToString:@"image"]) {
        NSDictionary *dic = value;
        _imageModel = [ImageModel new];
        [self.imageModel setValuesForKeysWithDictionary:dic];
    }
    if ([key isEqualToString:@"id"]) {
        self.ID = value;
    }
    
}
// 将tags数组里的字典 转换成model
-(void)setTags:(NSMutableArray *)tags{
    _tags = tags;
    
    NSMutableArray *array = [NSMutableArray array];
    
    for (NSDictionary *dic in tags) {
        tagsModel *tags = [[tagsModel alloc] init];
        [tags setValuesForKeysWithDictionary:dic];
        [array addObject:tags];
    }
    _tags = [NSMutableArray arrayWithArray:array];

}

@end
